<script setup lang="ts" name="ColorInput">
import { propTypes } from '@/utils/propTypes'
import { PREDEFINE_COLORS } from '@/utils/color'
/**
 * 颜色输入框
 * 输入框与颜色选择器是一个值，输入框内显示的是颜色选择器选择的颜色值
 */

const props = defineProps({
  modelValue: propTypes.string.def('')
})
const emit = defineEmits(['update:modelValue'])
const color = computed({
  get: () => {
    return props.modelValue
  },
  set: (val: string) => {
    emit('update:modelValue', val)
  }
})
</script>

<template>
  <ElInput v-model="color">
    <template #append>
      <ElColorPicker v-model="color" show-alpha :predefine="PREDEFINE_COLORS" />
    </template>
  </ElInput>
</template>

<style scoped lang="scss">
:deep(.el-input-group__append) {
  padding: 0;
}
</style>
